package sortAlgorithm;

/**
 * 希尔排序
 * 
 * @author YNS
 *
 */
public class ShellSort {
	public static int[] sort(int[] source) {
		int temp;

		for (int i = source.length / 2; i > 0; i /= 2) {
			for (int j = i; j < source.length; j++) {
				for (int k = j - i; k >= 0; k -= i) {
					if (source[k] > source[k + i]) {
						temp = source[k];
						source[k] = source[k + i];
						source[k + i] = temp;
					}
				}
			}
		}

		return source;
	}
}
